


PM_FUNC_NORM_ATTRIB AdminInit()
{
	pokemod_funcstart_debug( "AdminInit" );

	register_concmd( AdminCommand[ ADMIN_SETTING ],      "AdminSetting",      ADMIN_BAN, "<setting name> <value> - Changes values for settings" );
	register_concmd( AdminCommand[ ADMIN_GIVEPOKE ],     "AdminGivePoke",     ADMIN_BAN, "<nick | @TEAM | @ALL> <pokemon name> [level] - Gives the player(s) the pokemon at level 1 or at the specified level" );
	register_concmd( AdminCommand[ ADMIN_TAKEPOKE ],     "AdminTakePoke",     ADMIN_BAN, "<nick | @TEAM | @ALL> <pokemon name> - Removes the specified pokemon from the player(s)" );
	register_concmd( AdminCommand[ ADMIN_SETLEVEL ],     "AdminSetLevel",     ADMIN_BAN, "<nick | @TEAM | @ALL> <level> - Sets the player(s) active pokemon's level" );
	register_concmd( AdminCommand[ ADMIN_GIVEXP ],       "AdminGiveXP",       ADMIN_BAN, "<nick | @TEAM | @ALL> <exp> - Gives the player(s) active pokemon exp. points" );
	register_concmd( AdminCommand[ ADMIN_GIVEITEM ],     "AdminGiveItem",     ADMIN_BAN, "<nick | @TEAM | @ALL> <item> [amount] - Gives the player(s) 1 item or the amount specified" );
	register_concmd( AdminCommand[ ADMIN_GIVESKILL ],    "AdminGiveSkill",    ADMIN_BAN, "<nick | @TEAM | @ALL> <skill name> - Gives the player(s) active pokemon the skill specified" );
	register_concmd( AdminCommand[ ADMIN_SETLOCATION ],  "AdminSetLocation",  ADMIN_BAN, "<nick | @TEAM | @ALL> <location> - Teleports player(s) to the location specified" );
	register_concmd( AdminCommand[ ADMIN_FIGHTPOKE ],    "AdminFightPoke",    ADMIN_BAN, "<nick | @TEAM | @ALL> <pokemon name> <level> - Makes the player(s) fight the pokemon at the level specified" );

	pokemod_funcend_debug( "AdminInit" );
}


PM_FUNC_NORM_ATTRIB AdminGetPlayers( String:szName[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], &Int:iPlayerNum )
{
	if ( szName[ 0 ] == EOS )
		return 0;

	remove_quotes( szName );
	replace_all( szName, charsmax(szName), " ", "" );

	new Int:iUserID = -1;
	if ( szName[ 0 ] == '#' )
		iUserID = str_to_num( szName[ 1 ] );

	new String:szPlayerName[ NAME_LEN ];
	new Int:iFoundPlayer;

	LoopThroughPlayersFlags( iPlayerID, PLAYER_FLAGS_NOHLTV )
	{
		PlayerToName( iPlayerID, szPlayerName, charsmax(szPlayerName) );
		replace_all( szPlayerName, charsmax(szPlayerName), " ", "" );

		if ( iUserID != -1 && get_user_userid( iPlayerID ) == iUserID )
		{
			if ( iFoundPlayer )
			{
				return 0;
			}
			PlayerToName( iPlayerID, szName, charsmax(szName) );
			iFoundPlayer = iPlayerID;
		}
		else if ( containi( szPlayerName, szName ) != -1 )
		{
			if ( iFoundPlayer )
			{
				return 0;
			}
			PlayerToName( iPlayerID, szName, charsmax(szName) );
			iFoundPlayer = iPlayerID;
		}
	}

	if ( iFoundPlayer )
	{
		iPlayers[ 0 ] = iFoundPlayer;
		iPlayerNum = 1;
		return 1;
	}
	else
	{
		if ( equali( szName, "@ALL" ) || equal( szName, "*" ) )
		{
			copy( szName, charsmax(szName), "everyone" );
			get_players( iPlayers, iPlayerNum, PLAYER_FLAGS_NOHLTV );
		}

		else if ( szName[ 0 ] == '@' )
		{
			if ( toupper( szName[1] ) == 'T' )
			{
				copy( szName, charsmax(szName), "all Terrorists" );
				LoopThroughPlayersFlags( iPlayerID, PLAYER_FLAGS_NOHLTV )
				{
					if ( cs_get_user_team( iPlayerID ) != CS_TEAM_T )
						continue;
					iPlayers[ iPlayerNum ] = iPlayerID;
					iPlayerNum++;
				}
			}
			else if ( toupper( szName[1] ) == 'C' )
			{
				copy( szName, charsmax(szName), "all Counter-Terrorists" );
				LoopThroughPlayersFlags( iPlayerID, PLAYER_FLAGS_NOHLTV )
				{
					if ( cs_get_user_team( iPlayerID ) != CS_TEAM_CT )
						continue;
					iPlayers[ iPlayerNum ] = iPlayerID;
					iPlayerNum++;
				}
			}

			else if ( equali( szName[1], "BOT", 3 ) )
			{
				copy( szName, charsmax(szName), "all Bots" );
				get_players( iPlayers, iPlayerNum, PLAYER_FLAGS_BOTS );
			}

		}

		if ( iPlayerNum >= 1 )
		{
			return 1;
		}
	}
	return 0;
}


PM_FUNC_NORM_ATTRIB AdminMenu( Int:iAdminID )
{
	pokemod_funcstart_debug( "AdminMenu" );

	new Int:iMenu = MenuCreate( "PokeMod Admin" );

	MenuAddItem( iMenu, AdminCommand[ ADMIN_SETTING ],      "Server Settings" );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_GIVEPOKE ],     "Give Pokemon"    );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_TAKEPOKE ],     "Take Pokemon"    );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_SETLEVEL ],     "Set Level"       );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_GIVEXP ],       "Give XP"         );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_GIVEITEM ],     "Give Item"       );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_GIVESKILL ],    "Give Skill"      );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_SETLOCATION ],  "Set Location"    );
	MenuAddItem( iMenu, AdminCommand[ ADMIN_FIGHTPOKE ],    "Fight Pokemon" );

	MenuExit( iAdminID, iMenu, .bExitOption = true );

	MenuDisplay( iAdminID, iMenu, MENU_COMMAND );

	pokemod_funcend_debug( "AdminMenu" );
}

PM_FUNC_NORM_ATTRIB AdminCmdAccess( Int:iAdminID, Int:iCmdLevel )
{
	if ( g_iState == PM_DISABLED )
	{
		console_print( iAdminID, "PokeMod is disabled." );
		return 0;
	}

	new bool:bHasAccess = false
	if ( ( iCmdLevel == ADMIN_ADMIN && is_user_admin( iAdminID ) )
	|| ( ( get_user_flags( iAdminID ) & iCmdLevel ) == iCmdLevel )
	|| ( iCmdLevel == ADMIN_ALL ) )
	{
		bHasAccess = true;
	}

	if ( !bHasAccess )
	{
		console_print( iAdminID, "%L", iAdminID, "NO_ACC_COM" );
	}

	return bHasAccess;
}
PM_FUNC_PUBLIC_ATTRIB AdminActivity( Int:iAdminID, String:szText[] )
{
	new String:szName[ NAME_LEN ];
	PlayerToName( iAdminID, szName, charsmax(szName) );

	//Print to all players
	show_activity( iAdminID, szName, szText );

	//Print to the admin to let them know it happened
	console_print( iAdminID, "[PokeMod] %s", szText );
	client_print( iAdminID, print_chat, "[PokeMod] %s", szText );

	//Log the command used
	new String:szAuthID[ 35 ];
	get_user_authid( iAdminID, szAuthID, charsmax(szAuthID) );
	log_amx( "PokeMod: ^"%s<%d><%s><>^" %s",
		szName, get_user_userid( iAdminID ), szAuthID, szText );
}

PM_FUNC_PUBLIC_ATTRIB AdminSetting( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szSetting[ NAME_LEN ], POKE_SETTING:iSetting = SETTING_NULL;
	read_argv( 1, szSetting, charsmax(szSetting) );
	for ( new POKE_SETTING:iSettingNum; iSettingNum < POKE_SETTING; iSettingNum++ )
	{
		if ( equali( szSetting, SETTING_NAMES[ iSettingNum ] ) )
		{
			iSetting = iSettingNum;
			break;
		}
	}

	if ( iSetting == SETTING_NULL )
	{
		console_print( iAdminID, "[PokeMod] Select a setting from the menu" );

		new String:szValues[ _:POKE_SETTING ][ NAME_LEN ], Int:iValues;
		for ( new POKE_SETTING:iSettingNum; iSettingNum < POKE_SETTING; iSettingNum++ )
		{
			copy( szValues[ iValues++ ], charsmax( szValues[] ), SETTING_NAMES[ iSettingNum ] );
		}

		CommandValueMenu( iAdminID, szCommand, .szValueName = "Setting", .szValues = szValues, .iValues = iValues, .bReshow = false, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szValue[ NAME_LEN ];
	if ( !read_argv( 2, szValue, charsmax(szValue) ) )
	{
		console_print( iAdminID, "[PokeMod] Select a value from the menu" );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szSetting );

		new Float:fCurrentValue = SettingGetFloat( iSetting );

		new String:szValueNums[ 16 ][ NAME_LEN ], Int:iValues;
		switch ( iSetting )
		{
			case DAMAGE_AWAKEN, POKEDAMAGE_AWAKEN:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\%c1 - Yes", ( fCurrentValue ) ? 'y' : 'w' );
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\%c0 - No", ( !fCurrentValue ) ? 'y' : 'w' );
			}
			case TRAINING_SPAWN_BOOST:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f", fCurrentValue );
				for ( new Int:iValue; iValue <= 100; iValue += 5 )
				{
					if ( fCurrentValue != float( iValue ) )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%d", iValue );
				}
			}
			case SPAWN_DELAY, CHANGE_DELAY:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f Seconds", fCurrentValue );
				for ( new Int:iTime; iTime <= 30; iTime += 5 )
				{
					if ( fCurrentValue != float( iTime ) )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%d Seconds", iTime );
				}
			}
			case ARMOR_RATIO, ARMOR_BONUS:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f", fCurrentValue );
				for ( new Float:fValue = 0.0; fValue <= 1.0; fValue += 0.1 )
				{
					if ( fCurrentValue != fValue )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%0.1f", fValue );
				}
			}
			case BURN_DELAY, POISON_DELAY, CONFUSE_DELAY:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f", fCurrentValue );
				for ( new Float:fValue = 0.0; fValue <= 10.0; fValue += 0.5 )
				{
					if ( fCurrentValue != fValue )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%0.1f", fValue );
				}
			}
			case BURN_DAMAGE, POISON_DAMAGE, FROZEN_DAMAGE:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f Damage", fCurrentValue );
				for ( new Int:iValue = 5; iValue <= 50; iValue += 5 )
				{
					if ( fCurrentValue != float( iValue ) )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%d Damage", iValue );
				}
			}
			case BURN_RADIUS:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f", fCurrentValue );
				for ( new Int:iValue = 50; iValue <= 500; iValue += 50 )
				{
					if ( fCurrentValue != float( iValue ) )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%d", iValue );
				}
			}
			case OAK_HEALTH:
			{
				formatex( szValueNums[iValues++], charsmax(szValueNums[]), "\y%0.1f", fCurrentValue );
				for ( new Int:iValue = 0; iValue <= 1000; iValue += 50 )
				{
					if ( fCurrentValue != float( iValue ) )
						formatex( szValueNums[iValues++], charsmax(szValueNums[]), "%d", iValue );
				}
			}
		}

		CommandValueMenu( iAdminID, szCommand, .szValueName = szSetting, .szValues = szValueNums, .iValues = iValues, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	SettingSetValue( iSetting, szValue );

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Set %s to %s", SETTING_NAMES[ iSetting ], szValue );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}

PM_FUNC_PUBLIC_ATTRIB AdminGivePoke( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szPokemon[ NAME_LEN ], Int:iPokeID;
	read_argv( 2, szPokemon, charsmax(szPokemon) );
	if ( ( iPokeID = NameToPoke( szPokemon, .playerID = iAdminID ) ) == -1 )
	{
		console_print( iAdminID, "[PokeMod] Select a pokemon from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		CommandPokeMenu( iAdminID, szCommand, .bOnlyOwned = false, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szLevel[ NAME_LEN ], Int:iLevel;
	read_argv( 3, szLevel, charsmax(szLevel) );
	iLevel = max( 1, str_to_num( szLevel ) ); 

	for ( new Int:i; i < iPlayerNum; i++ )
	{
		PlayerGivePoke( iPlayers[ i ], iPokeID, .level = iLevel, .giverID = iAdminID );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Gave %s a level %d %s", szPlayer, iLevel, PokeToName( iPokeID ) );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminTakePoke( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szPokemon[ NAME_LEN ], Int:iPokeID;
	read_argv( 2, szPokemon, charsmax(szPokemon) );
	if ( ( iPokeID = NameToPoke( szPokemon, .playerID = iAdminID ) ) == -1 )
	{
		console_print( iAdminID, "[PokeMod] Select a pokemon from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		if ( iPlayerNum > 1 )
			CommandPokeMenu( iAdminID, szCommand, .bOnlyOwned = false, .bReshow = true, .bAdminCmd = true );
		else
			CommandPokeMenu( iAdminID, szCommand, .bOnlyOwned = true, .iOwner = iPlayers[0], .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	for ( new Int:i, Int:iPlayer, iPokeNum; i < iPlayerNum; i++ )
	{
		iPlayer = iPlayers[i];
		for ( iPokeNum = 0; iPokeNum < POKEMON_PER_PLAYER; iPokeNum++ )
		{
			if ( g_iPlayerPokemonStats[ iPlayer ][ iPokeNum ][ POKESTAT_POKEMON ] == iPokeID )
			{
				//If it's their active pokemon, change their active pokemon
				if ( iPokeNum == PlayerGetInfo( iPlayer, PINFO_ACTIVE_POKENUM ) )
					PlayerSetInfo( iPlayer, PINFO_ACTIVE_POKENUM, ( iPokeNum + 1 ) % POKEMON_PER_PLAYER )

				PlayerRelease( iPlayer, iPokeNum );
			}
		}
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Made %s release %s", szPlayer, PokeToName( iPokeID ) );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminSetLevel( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szLevel[ NAME_LEN ], Int:iLevel;
	read_argv( 2, szLevel, charsmax(szLevel) );
	if ( !( iLevel = str_to_num( szLevel ) ) )
	{
		console_print( iAdminID, "[PokeMod] Select a level from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		new String:szNumbers[][] = {"1","10","25","30","40","50","60","75","80","90","100"};
		CommandValueMenu( iAdminID, szCommand, .szValueName = "Level", .szValues = szNumbers, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	for ( new Int:i, Int:iPlayerID, Int:iPokeNum, Int:xpAmount, Int:xpType;
		i < iPlayerNum;
		i++
	){
		iPlayerID = iPlayers[ i ];
		iPokeNum = PlayerGetInfo( iPlayerID, PINFO_ACTIVE_POKENUM );

		xpType = g_iPlayerPokemonStats[ iPlayerID ][ iPokeNum ][ POKESTAT_XP_TYPE ];
		xpAmount = LevelToXP( iLevel - 1, xpType ) - g_iPlayerPokemonStats[ iPlayerID ][ iPokeNum ][ POKESTAT_XP ];

		PlayerGiveXP( iPlayerID, iPokeNum, xpAmount );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Set %s to level %d.", szPlayer, iLevel );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminGiveXP( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szXP[ NAME_LEN ], Int:xpAmount;
	read_argv( 2, szXP, charsmax(szXP) );
	if ( !( xpAmount = str_to_num( szXP ) ) )
	{
		console_print( iAdminID, "[PokeMod] Select a number from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		new String:szNumbers[][] = {"100","250","500","1000","5000","10000","50000","-100","-250","-500","-1000","-5000","-10000","-50000"};
		CommandValueMenu( iAdminID, szCommand, .szValueName = "XP", .szValues = szNumbers, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	for ( new Int:i, Int:iPlayerID; i < iPlayerNum; i++ )
	{
		iPlayerID = iPlayers[ i ];
		PlayerGiveXP( iPlayerID, PlayerGetInfo( iPlayerID, PINFO_ACTIVE_POKENUM ), xpAmount );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Gave %s %d experience.", szPlayer, xpAmount );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminGiveItem( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szItem[ NAME_LEN ], Int:iItemID;
	read_argv( 2, szItem, charsmax(szItem) );
	if ( ( iItemID = NameToItem( szItem, .playerID = iAdminID ) ) == -1 )
	{
		console_print( iAdminID, "[PokeMod] Select an item from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		CommandItemMenu( iAdminID, szCommand, .bOnlyOwned = false, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szAmount[ NAME_LEN ], Int:iAmount;
	read_argv( 3, szAmount, charsmax(szAmount) );
	iAmount = max( 1, str_to_num( szAmount ) ); 

	for ( new Int:i; i < iPlayerNum; i++ )
	{
		PlayerGiveItem( iPlayers[ i ], iItemID, iAmount );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Gave %s %d %s", szPlayer, iAmount, ItemToName( iItemID ) );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminGiveSkill( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szSkill[ NAME_LEN ], POKESKILL:iSkillID;
	read_argv( 2, szSkill, charsmax(szSkill) );
	if ( ( iSkillID = NameToSkill( szSkill, .playerID = iAdminID ) ) == SKILL_INVALID )
	{
		console_print( iAdminID, "[PokeMod] Select a skill from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		CommandSkillMenu( iAdminID, szCommand, .bOnlyOwned = false, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	for ( new Int:i, Int:iPlayerID; i < iPlayerNum; i++ )
	{
		iPlayerID = iPlayers[ i ];
		SkillLearn( iPlayerID, PlayerGetInfo( iPlayerID, PINFO_ACTIVE_POKENUM ), iSkillID );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Gave %s the skill %s", szPlayer, SkillToName( iSkillID ) );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminSetLocation( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szLocation[ NAME_LEN ], Int:iLocation;
	read_argv( 2, szLocation, charsmax(szLocation) );
	if ( ( iLocation = NameToLocation( szLocation, .playerID = iAdminID ) ) == -1 )
	{
		console_print( iAdminID, "[PokeMod] Select a location from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		CommandLocationMenu( iAdminID, szCommand, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	for ( new Int:i; i < iPlayerNum; i++ )
	{
		LocationSet( iPlayers[ i ], iLocation );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Teleported %s to %s", szPlayer, LocationToName( iLocation ) );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}
PM_FUNC_PUBLIC_ATTRIB AdminFightPoke( Int:iAdminID, Int:iCmdLevel )
{
	if ( !AdminCmdAccess( iAdminID, iCmdLevel ) )
		return PLUGIN_HANDLED;

	new String:szCommand[ 64 ], Int:iLen;
	iLen = read_argv( 0, szCommand, charsmax(szCommand) );

	new String:szPlayer[ NAME_LEN ], Int:iPlayers[ MAX_PLAYERS ], Int:iPlayerNum;
	read_argv( 1, szPlayer, charsmax(szPlayer) );
	if ( !AdminGetPlayers( szPlayer, iPlayers, iPlayerNum ) )
	{
		console_print( iAdminID, "[PokeMod] Select a player from the menu" );
		CommandPlayerMenu( iAdminID, szCommand, .bAllowSelf = true, .bAllowMultiple = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szPokemon[ NAME_LEN ], Int:iPokemon;
	read_argv( 2, szPokemon, charsmax(szPokemon) );
	if ( ( iPokemon = NameToPoke( szPokemon, .playerID = iAdminID ) ) <= 0 )
	{
		console_print( iAdminID, "[PokeMod] Select a pokemon from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s", szPlayer );
		CommandPokeMenu( iAdminID, szCommand, .bOnlyOwned = false, .bReshow = false, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	new String:szLevel[ NAME_LEN ], Int:iLevel;
	read_argv( 3, szLevel, charsmax(szLevel) );
	if ( !( iLevel = str_to_num( szLevel ) ) )
	{
		console_print( iAdminID, "[PokeMod] Select a level from the menu" );
		read_argv( 1, szPlayer, charsmax(szPlayer) );
		formatex( szCommand[ iLen ], charsmax(szCommand) - iLen, " %s %s", szPlayer, szPokemon );
		new String:szNumbers[][] = {"1","10","25","30","40","50","60","75","80","90","100"};
		CommandValueMenu( iAdminID, szCommand, .szValueName = "Level", .szValues = szNumbers, .bReshow = true, .bAdminCmd = true );
		return PLUGIN_HANDLED;
	}

	for ( new Int:i; i < iPlayerNum; i++ )
	{
		EncounterForce( iPlayers[ i ], iPokemon, iLevel );
	}

	new String:szActivity[ 128 ];
	formatex( szActivity, charsmax(szActivity), "Made %s fight a level %d %s", szPlayer, iLevel, PokeToName( iPokemon ) );
	AdminActivity( iAdminID, szActivity );

	return PLUGIN_HANDLED;
}

